import sys,os
    
out = open(sys.argv[2], "w")
ini = open(sys.argv[1])
while ini:
    read1 = ini.readline()
    if read1.startswith("@"):
        out.write(read1)
        continue
    read2 = ini.readline()
    read1name = read1.split("\t")[0]
    read2name = read2.split("\t")[0]
    # if read1name == "V350159414L1C001R00100001861" or read2name == "V350159414L1C001R00100001861":
    #     print(read1)
    #     print(read2)
    while read1name != read2name:
        #print(read1)
        read1 = read2
        read2 = ini.readline()
        read1name = read1.split("\t")[0]
        read2name = read2.split("\t")[0]
    out.write(read1)
    out.write(read2)
    
